package com.example.bpmn.listener;

import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.ExecutionListener;
import org.springframework.stereotype.Component;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.example.bpmn.event.ProcessEvent;
import com.example.bpmn.service.ProcessEventPublisher;
import com.example.bpmn.domain.OrderStatus;

@Slf4j
@Component
public class ProcessEventListener implements ExecutionListener {
    
    @Override
    public void notify(DelegateExecution execution) throws Exception {
        String eventName = execution.getEventName();
        String activityId = execution.getCurrentActivityId();
        String processInstanceId = execution.getProcessInstanceId();
        
        log.info("流程事件通知: event={}, activity={}, processInstance={}", 
            eventName, activityId, processInstanceId);
            
        // 根据事件类型处理
        switch (eventName) {
            case EVENTNAME_START:
                handleStart(execution);
                break;
            case EVENTNAME_END:
                handleEnd(execution);
                break;
            default:
                log.warn("未知的事件类型: {}", eventName);
        }
    }
    
    private void handleStart(DelegateExecution execution) {
        // 处理开始事件...
    }
    
    private void handleEnd(DelegateExecution execution) {
        // 处理结束事件...
    }
} 